@extends('admin.layout.layout', ['row' => @$page])

@section('contain')


    <div class="portlet">
        <div class="portlet-title">
            <div class="caption">
                <x-portlet-breadcrumb :page="$page"></x-portlet-breadcrumb>
            </div>
            <div class="actions">
                {{--<div class="item">
                    <a href="/{{ request()->path() }}/create" class="btn btn-sm btn-primary">{{ ts('addnew') }}</a>
                </div>--}}
            </div>
        </div>

        <div class="my-3 bg-light p-3 px-4">
            <div class="row">
                <div class="col-auto">
                    <b>{{ ts('DISTRIBUTORID') }}：</b>
                    <span>{{ @$user->id }}</span>
                </div>
                <div class="col-auto">
                    <b>{{ ts('companyname') }}：</b>
                    <span>{{ @$user->company_name }}</span>
                </div>
                <div class="col-auto">
                    <b>{{ ts('PHONENUMBER') }}：</b>
                    <span>{{ @$user->phone_number }}</span>
                </div>
            </div>
        </div>

        <div class="filter-wrapper">
            <form action="/{{ request()->path() }}/" class="form-inline filter-form">
                <div class=" input-group mb-3 custom-control-inline">
                    <div class="input-group-prepend">
                        <select name="label" class="form-control">
                            <option value="id" {{ request()->input('label') == 'warranty_id' ? 'selected' : '' }}>{{ ts('warrantyid') }}</option>
                            <option value="first_name" {{ request()->input('label') == 'first_name' ? 'selected' : '' }}>{{ ts('CUSTOMERNAME') }}</option>
                            <option value="phone_number" {{ request()->input('label') == 'phone_number' ? 'selected' : '' }}>{{ ts('contactinformation') }}</option>
                            {{--<option value="roll_number" {{ request()->input('label') == 'roll_number' ? 'selected' : '' }}>{{ ts('rollnumber') }}</option>--}}
                        </select>
                    </div>
                    <input type="text" class="form-control" name="value" value="{{ request()->input('value') }}">
                </div>
                <div class=" input-group mb-3 custom-control-inline flatpickr-date-range">
                    <div class="input-group-prepend">
                        <span class="input-group-text">{{ ts('DATESOLD') }}</span>
                    </div>
                    <input type="text" name="startdate" placeholder="{{ ts('SESECTDATE') }}" class="startdate flatpickr form-control" value="{{ request()->input('startdate') }}">
                    <div class="input-group-prepend">
                        <span class="input-group-text">{{ ts('DATE') }}</span>
                    </div>
                    <input type="text" name="enddate" placeholder="{{ ts('SESECTDATE') }}" class="enddate flatpickr form-control" value="{{ request()->input('enddate') }}">
                </div>
                <div class="mb-3">
                    <button class="btn btn-primary">{{ ts('SEARCH') }}</button>
                    <a href="/{{ request()->path() }}/" class="btn btn-warning">{{ ts('RESET') }}</a>
                </div>
            </form>
        </div>

        <div>
            <table class="table table-s1">
                <thead>
                <tr>
                    <th>{{ ts('WARRANTYID') }}</th>
                    <th>{{ ts('DEALERNAME') }}</th>
                    <th>{{ ts('CUSTOMERNAME') }}</th>
                    <th>{{ ts('ROLLID') }}</th>
                    <th>{{ ts('length') }}</th>
                    <th>{{ ts('installationdate') }}</th>
                    <th style="width:270px">{{ ts('OPTION') }}</th>
                </tr>
                </thead>
                <tbody>
                @foreach($data as $v)
                    <tr class="item-list">
                        <td>
                            <div class="truncated-3">{{ @$v->id }}</div>
                        </td>
                        <td>
                            <div class="truncated-3">{{ @$v->dealer->company_name }}</div>
                        </td>
                        <td>
                            <div class="truncated-3">{{ @$v->first_name }}</div>
                        </td>
                        <td>
                            <div class="truncated-3">
                                @foreach(@$v->warranty_to_vehicle_coverage as $r)
                                    <div>{{ $r->roll_number }}：{{ $r->length }}</div>
                                @endforeach
                            </div>
                        </td>
                        <td class="roll-sales-length">
                            <div class="truncated-3">{{ array_sum(\Illuminate\Support\Arr::pluck(@$v->warranty_to_vehicle_coverage, 'length')) }}</div>
                        </td>
                        <td>
                            <div class="truncated-3">{{ $v->installation_date }}</div>
                        </td>
                        <td>
                            <a class="btn btn-success btn-sm" href='/admin/warranty/{{ $v->id }}' target="_blank">{{ ts('VIEW') }}</a>
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
            <div class="text-right my-3">
                <span class="alert alert-primary d-inline-block mb-0">
                    {{ ts('rollsalesstatistics') }}：<span class="text-danger roll-saless-tatistics"></span>
                </span>
            </div>
            <div class="my-3">
                {{ $data->appends(request()->input())->links() }}
            </div>
        </div>

    </div>


@endsection